<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    .box {
      width: 600px;
      height: 600px;
      background-color: #f00;

      /* 设置背景图片 */
      background-image: url(../images/kobe01.jpg);
      background-repeat: no-repeat;

      /* 设置背景的尺寸 */
      /* background-size: 100% 100%; */
      /* background-size: 100px 100px; */
      /*
      contain 保持图片的宽高比，缩放至最大尺寸
       cover 保持图片的宽高比，缩放至完全覆盖
       auto 保持图片的宽高比，缩放至完全显示
       100px auto 只设置宽度，高度自动计算保持宽高比*/
      background-size: 100px auto;
    }
  </style>
</head>
<body>
  
  <div class="box"></div>

</body>
</html>